package com.yida.gwj.api.factory;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.yida.common.core.domain.R;
import com.yida.gwj.api.domain.GwjMaintenanceFundsBusinessInner;
import com.yida.gwj.api.domain.request.GwjExpendOutSideAllocatedAmountHouseRequest;
import com.yida.gwj.api.service.RemoteGwjExpendService;

/**
 * 公维金服务降级处理
 *
 * @author hmh
 */
@Component
public class RemoteGwjExpendFallbackFactory implements FallbackFactory<RemoteGwjExpendService> {

    private static final Logger log = LoggerFactory.getLogger(RemoteGwjExpendFallbackFactory.class);

    @Override
    public RemoteGwjExpendService create(Throwable throwable) {
        log.error("公维金外网支出服务调用失败:{}", throwable.getMessage());
        return new RemoteGwjExpendService() {
            @Override
            public R<JSONArray> expendImg(Long bizNum, Long areaId, String source) {
                return R.fail("查询支出外网图片失败:{}" + throwable.getMessage());
            }

            @Override
            public R<JSONObject> expendFile(Long bizNum, Long areaId, String source) {
                return R.fail("查询支出外网文件失败:{}" + throwable.getMessage());
            }

            @Override
            public R<JSONObject> expendBusinessHouse(GwjExpendOutSideAllocatedAmountHouseRequest gwjExpendOutSideAllocatedAmountHouseRequest, String source) {
                return R.fail("查询支出外网业务已选中房屋失败:{}" + throwable.getMessage());
            }

            @Override
            public R<JSONObject> expendBusinessHouseUnselected(GwjExpendOutSideAllocatedAmountHouseRequest gwjExpendOutSideAllocatedAmountHouseRequest, String source) {
                return R.fail("查询支出外网业务未选中房屋失败:{}" + throwable.getMessage());
            }

            @Override
            public R<JSONArray> expendBusinessBuilds(Long bizNum, Long areaId, String source) {
                return R.fail("查询支出外网业务未选中房屋失败:{}" + throwable.getMessage());
            }

            @Override
            public R<GwjMaintenanceFundsBusinessInner> getMaintenanceFundsBusinessInfoByBizId(Long bizId, String source) {
                return R.fail("公维金公共维修资金业务信息查询失败:{}" + throwable.getMessage());
            }

            @Override
            public R<Boolean> resultNotify(String jsonMsg, String source) {
                return R.fail("公维金公共维修资金业务信息步骤回调:{}" + throwable.getMessage());
            }

            @Override
            public R<Boolean> rollbackResultNotify(String jsonMsg, String source) {
                return R.fail("公维金公共维修资金业务信息回退步骤回调:{}" + throwable.getMessage());
            }

            @Override
            public R<Boolean> preAcceptExamine(String jsonMsg, String source) {
                return R.fail("公维金公共维修资金业务信息预受理审核:{}" + throwable.getMessage());
            }

            @Override
            public R selectHouseAndOwnerVoteInfo(String outServerIdentification, String source) {
                return R.fail("公维金公共维修资金业务信息查询房屋业主投票列表{}"+throwable.getMessage());
            }

            @Override
            public R<JSONObject> ownerCheckInner(String outServerIdentification,Integer bizFlagId, String source) {
                return R.fail("公维金公共维修资金业务信息查询业主证明:{}"+throwable.getMessage());
            }

        };
    }

}
